class Order < ActiveRecord::Base
  belongs_to :user
  PAYMENT_TYPES = [ "网银支付", "支付宝","微信支付","拉卡拉" ]
  # ...
  validates :name, :address, :email, :pay_type, :presence => true
  validates :pay_type, :inclusion => PAYMENT_TYPES

  has_many :line_items, :dependent => :destroy
 
  
  # ...
  # ...
  def add_line_items_from_cart(cart)
    cart.line_items.each do |item|
      item.cart_id = nil
      line_items << item
    end
  end
end